The present invention relates to a semiconductor device and a control method thereof, and more particularly, to a semiconductor device having a real-time trace function and a control method thereof.
To debug a program in a microcomputer, it is effective to hold a history (hereinafter referred to as “trace information”) of a program counter to be executed by the microprocessor. This trace information is analyzed afterwards to thereby debug the program. In addition, in recent years, there is a demand for holding the trace information in real time without interrupting the operation of the microcomputer. That is, there is a demand for having a real-time trace function.
Japanese Unexamined Patent Application Publication No. 05-224989 discloses a related art. FIG. 6 is a diagram illustrating a trace system disclosed in Japanese Unexamined Patent Application Publication No. 05-224989. In the trace system illustrated in FIG. 6, a trace analyzer 103 loads a mode display signal 105, an instruction execution start signal 106, a branch instruction generation signal 107, and an interrupt branch generation signal 108, each of which is output from a microprocessor 101. The trace analyzer 103 writes address information, which is acquired based on these pieces of information, into a trace memory 104, thereby tracing instructions. This enables the trace system illustrated in FIG. 6 to hold the trace information without interrupting the operation of the microprocessor 101.